package cn.itsource.xhy.org.service.impl;

import cn.itsource.xhy.org.domain.SystemType;
import cn.itsource.xhy.org.mapper.SystemTypeMapper;
import cn.itsource.xhy.org.query.SystemTypeQuery;
import cn.itsource.xhy.org.service.ISystemTypeService;
import cn.itsource.xhy.utils.QueryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class SystemTypeServiceImpl implements ISystemTypeService {

    @Autowired
    private SystemTypeMapper systemTypeMapper;

    @Override
    @Transactional
    public void save(SystemType systemTypr) {
        systemTypeMapper.save(systemTypr);
    }

    @Override
    @Transactional
    public void update(SystemType systemTypr) {
        systemTypeMapper.update(systemTypr);
    }

    @Override
    @Transactional
    public void del(Long id) {
        systemTypeMapper.del(id);
    }

    @Override
    public SystemType findById(Long id) {
        return systemTypeMapper.findById(id);
    }

    @Override
    public List<SystemType> findAll() {
        return systemTypeMapper.findAll();
    }

    @Override
    public QueryResult<SystemType> queryPage(SystemTypeQuery query) {
        Long total = systemTypeMapper.count(query);
        if (total==null||total == 0){
            return new QueryResult<>();
        }
        List<SystemType> data = systemTypeMapper.queryPage(query);
        return new QueryResult<>(data,total);
    }

    @Override
    @Transactional
    public void patchDel(Long[] ids) {
        systemTypeMapper.patchDel(ids);
    }
}
